package com.srit.forecast.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.srit.forecast.bean.Broadcast;
import com.srit.forecast.controller.vo.BroadCastVO;
import com.srit.forecast.dao.BroadcastDao;
import com.srit.system.bean.CodeType;
import com.srit.system.dao.CodeTypeDao;


/**
 * 广播稿controller
 * @author chenxiling
 *
 */
@Controller
public class BroadcastController {
	
	protected final transient Log log = LogFactory   
		    .getLog(BroadcastController.class);   
	@Autowired(required = true)
	private BroadcastDao broadcastDao;
	@Autowired(required = true)
	private CodeTypeDao codeTypeDao;
	
	@RequestMapping(value="views/broadcastSave")
	public String save(HttpServletRequest request,ModelMap modelMap)throws Exception{
		return "broadcast";
	}
	
	@RequestMapping(value="views/broadcastSaveBefore")
	public String load(ModelMap modelMap){
		int max = broadcastDao.getMaxId();
		Broadcast bc = broadcastDao.getById(max);
		modelMap.put("broadcast", bc);
		return "broadcast";
	}
	@RequestMapping(value="views/broadcastForm")
	public String form(@ModelAttribute BroadCastVO braodCastVO,ModelMap modelMap){
		List<CodeType> codeTypeList = codeTypeDao.listOnDrag();// 暂时所有的
		modelMap.addAttribute("codeTypeList", codeTypeList);
		return "broadcast";
	}

}
